/**
 * 字段状态
 */
var dicts = [{
        category: "MALL_VEHICLE_STATUS",
        code: "DRAFT",
        des: "草稿状态",
        id: 1987,
        name: "草稿",
        sequence: 1,
        state: 0
    },
    {
        category: "MALL_VEHICLE_STATUS",
        code: "VERIFYING",
        des: "",
        id: 1988,
        name: "审核中",
        sequence: 2,
        state: 0
    },
    {
        category: "MALL_VEHICLE_STATUS",
        code: "ONSELLING",
        des: "上架状态",
        id: 1989,
        name: "已上架",
        sequence: 3,
        state: 0
    },
    {
        category: "MALL_VEHICLE_STATUS",
        code: "PUTOFF",
        des: "下架状态",
        id: 1990,
        name: "已下架",
        sequence: 4,
        state: 0
    },
    {
        category: "MALL_VEHICLE_STATUS",
        code: "SOLD",
        des: "",
        id: 1991,
        name: "已过户",
        sequence: 5,
        state: 0
    },
    {
        category: "MALL_VEHICLE_STATUS",
        code: "VERIFY_FAIL",
        des: "",
        id: 1992,
        name: "审核不通过",
        sequence: 6,
        state: 0
    }
];


var CarList = [{
    brandModel: null,
    evaluated: 0,
    id: 1,
    insertTime: null,
    location: "厦门市",
    memberCode: null,
    memberName: null,
    mileage: 10,
    name: "奥迪 A6L 2009款 2.0 TFSI 标准型(自动)",
    newCarPrice: 46.54,
    price: 8.88,
    status: "VERIFYING",
    statusStr: null,
    top: 0,
    vin: null
}]


const transformDict = (arr, dicts,replaceKey="status") => {
    if (Array.isArray(arr)) {
        arr.forEach((item1, index1, self1) => {
            dicts.forEach((item2, index2, self2) => {
                if(item1.status==item2.code){
                    item1[replaceKey]={...item2}
                }
            })
        })
    }
    console.log(arr)
    return arr;
}

transformDict(CarList, dicts);